<?php
/**
 * Created by PhpStorm.
 * User: zhangbing
 * Date: 2017/3/13 0013
 * Time: 18:12
 */
namespace app\admin\validate;
use think\Validate;

class User extends Validate{
    //定义验证规则
    protected $rule = [
        'username' => 'require|max:25|unique:user',
        'password' => 'require|length:6,18',
        'real_name'=> 'require',

    ];

    //定义错误信息
    protected $message = [
        'username.require' => '用户名不能为空',
        'username.max'     => '用户名不能超过25个字符',
        'password.require' => '密码不能为空',
        'password.length'  => '密码长度为6-18位',
        'username.unique'  => '用户名已存在',
        'real_name.require'=> '真实姓名必填',
    ];

    //验证场景
    protected $scene = [
        'login'  =>  ['username','password'],
        'userAdd'=>  ['username'],
        'userProduct' => ['username','real_name'],
    ];
}
